package com.xm.servlet.background.orders;

import com.google.gson.Gson;
import com.xm.entity.LogisticsCompanies;
import com.xm.service.background.LogisticsCompaniesService;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 新增物流公司
 * @author 康文程
 * @date 2024-1-13
 */
@WebServlet("/background/new/logistics/companies")
public class NewLogisticsCompaniesServlet extends HttpServlet {
    private final LogisticsCompaniesService service = new LogisticsCompaniesService();
    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String logisticsCompaniesJson = req.getParameter("logisticsCompaniesJson");
        LogisticsCompanies logisticsCompanies = new Gson().fromJson(logisticsCompaniesJson, LogisticsCompanies.class);
        service.addLogisticsCompanies(logisticsCompanies);
    }
}
